# 17级智能移动班 李翔宇  17114120208
import random
RANKS = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
SUITS = ['梅花', '方片', '红桃', '黑桃']
D = {}
E = {}


class Card:
    def __init__(self, id, rank, suit, is_face_up):
        self.id = id
        self.rank = rank
        self.suit = suit
        self.is_face_up = True


class play:
    @staticmethod
    def populate():  #
        for i in range(4):
            su = SUITS[i]
            for n in range(13):
                D[n+13*i] = Card(n, RANKS[n], su, True)
        D[52] = Card(13, '大王', '', True)
        D[53] = Card(14, '小王', '', True)

    @staticmethod
    def shuffle(a):
        L = random.sample(range(0, a), a)
        for i in range(a):
            b = int(L[i]/54)
            E[i] = D[L[i]-54*b]

    @staticmethod
    def deal(b, c):  # 发牌
        A = {}
        for i in range(b):
            A[i] = E[i+b*c]
        return A

    @staticmethod
    def flip(Card):
        Card.is_face_up = False

    @staticmethod
    def pic_order(Card):
        return Card.id


class Hand:
    def __init__(self, cards):
        self.cards = cards

    def __paixu__(self):
        for j in range(24):
            for i in range(24-j):
                if(self.cards[i].id <= self.cards[i+1].id):
                    temp = self.cards[i]
                    self.cards[i] = self.cards[i+1]
                    self.cards[i+1] = temp

    def __str__(self):  # 输出手里的牌
        self.__paixu__()
        str1 = ''
        for i in range(25):
            str1 = str1 +\
                self.cards[i].suit+self.cards[i].rank+'\t'
        return str1

    def outP(self, n):  # 出牌
        str2 = self.cards[n].suit+self.cards[n].rank+'\t'
        del self.cards[n]
        return str2

    def SuoHa(self):  # 梭哈
        self.cards.clear()


play.populate()  # 洗牌
play.shuffle(108)
Hand1 = Hand(play.deal(25, 0))
Hand2 = Hand(play.deal(25, 1))
Hand3 = Hand(play.deal(25, 2))
Hand4 = Hand(play.deal(25, 3))
print("==================================================================================================================")
print('牌手1：', Hand1)
print('牌手2：', Hand2)
print('牌手3：', Hand3)
print('牌手4：', Hand4)
